package com.shop2cn.iapi.agentproducts.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.ExistByProductCodeBean;
import com.shop2cn.iapi.agentproducts.service.ExistByProductCodeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
/**
*根据商品编码查询是否存在
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ExistByProductCode{
	private static ExistByProductCodeBean existbyproductcodeBean;
	private static ExistByProductCodeCall existbyproductcodeCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据商品编码查询是否存在");
	}

	@Before
	public void caseUp() {
		existbyproductcodeBean=new ExistByProductCodeBean();
		existbyproductcodeCall=new ExistByProductCodeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(existbyproductcodeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ExistByProductCode_001() {
		Logger.start(true,"商户编号与商品编码正确,成功");
		try {
			existbyproductcodeBean.setUserId(288484);
			existbyproductcodeBean.setProductCode("shangpinhuohao123456");
			existbyproductcodeCall.setData(existbyproductcodeBean);
			existbyproductcodeCall.callService();	
			Logger.verifyEquals("200",existbyproductcodeCall.getJsonObject().get("code").toString(),"验证报文code");
			Logger.verifyEquals(true,existbyproductcodeCall.getJsonObject().get("data").getAsJsonObject().get("exist").getAsBoolean(),"判断是否查询出来");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ExistByProductCode_002() {
		Logger.start(true,"商户编号与商品编码错误,失败");
		try {
			existbyproductcodeBean.setUserId(288484);
			existbyproductcodeBean.setProductCode("666");
			existbyproductcodeCall.setData(existbyproductcodeBean);
			existbyproductcodeCall.callService();	
			Logger.verifyEquals("500",existbyproductcodeCall.getJsonObject().get("code").toString(),"验证报文code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ExistByProductCode_003() {
		Logger.start(true,"商品编号为空,失败");
		try {
			existbyproductcodeBean.setUserId(288484);
			existbyproductcodeBean.setProductCode("");
			existbyproductcodeCall.setData(existbyproductcodeBean);
			existbyproductcodeCall.callService();	
			Logger.verifyEquals("400",existbyproductcodeCall.getJsonObject().get("code").toString(),"验证报文code");
			Logger.verifyEquals("null",existbyproductcodeCall.getJsonObject().get("data").toString(),"商品编号为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}